<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.5/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.5/themes/icon.css">
		<script type="text/javascript" src="js/jquery-easyui-1.4.5/jquery.min.js"></script>
		<script type="text/javascript" src="js/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="js/jquery-easyui-1.4.5/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript" src="js/jquery-2.1.0.js"></script>
		<link rel="stylesheet" type="text/css" href="css/block.css" />
		<style type="text/css">
			
		</style>
		<script>
		//加载界面
		var bid=1;//板块id ,默认为1
		var sortway=1;//排序方式  默认为1  1代表按回复时间  2代表点赞量
		var bnames=["啊啊啊","美食推荐","厨艺交流","饮食健康","日常分享"];

		//显示所有板块和主贴
		function show(){
			$.ajax({
				type:"post",
				url:"block?method=showByuid",
				dataType:"json",
				data:{
					
					'sortway':sortway
				},
				success:function(d){
					console.log(d);
					
					var tlist=d.mlist;
					
					for(var i=0;i<tlist.length;i++){
						var ttr=$("<tr class='mpost'></tr>");
						ttr.append("<td  width=\"370px\" onclick=tiao("+tlist[i].mid+")>"+tlist[i].mtitle+"</td>");
						ttr.append("<td  width=\"100px\">"+bnames[tlist[i].bid]+"</td>");
						ttr.append("<td  width=\"50px\">"+tlist[i].mcount+"</td>");
						ttr.append("<td  width=\"200px\">"+tlist[i].mdate+"</td>");
						ttr.append("<td style=\"visibility: hidden;width:0px;\">"+tlist[i].bid+"</td>")
						
						$("#dg").append(ttr);
					}
				}
			});
		}

		//清空板块和   主贴信息
		function clear(){
			$("#dg tr").not(":eq(0)").empty();
			
		}
		function tiao(mid){
			
			console.log(mid);
			$.ajax({
				type:"post",
				url:"block?method=toreply",
				dataType:"json",
				data:{
					"mid":mid
				},
				success:function(d){
					console.log("success");
					window.parent.location.href="User-reply.html";
				}
			
			});
		}
			$(function(){
				show();

				$("#fabu").click(function(){
					sortway=1;
					clear();
					show();
				});
				$("#zan").click(function(){
					sortway=2;
					clear();
					show();
				});
			
			});
		</script>
	</head>

	<body>
				<div id="right">
					
					<div id="sort">
						&nbsp
						<a href="#" id="fabu">最新发布</a>&nbsp;&nbsp;&nbsp;
						<a href="#" id="zan">高赞热贴</a>
					</div>
					<div id="d1">

						<table id="dg"  style="width:970px; border:false;background: #fff;" border='0' cellspacing='0' cellpadding='0' " >
								<tr id="tr0">
									<th  width="370px">标题</th>
									<th  width="100px">板块</th>
									<th width="50px">获赞</th>
									<th  width="200px">发帖时间</th>
									<th  style="visibility: hidden;width:0px;"></th>									
								</tr>
							
						</table>
					</div>
				</div>			
	</body>

</html>